﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TimeTracker_Entities;
using System.ComponentModel.DataAnnotations;

namespace TimeTracker.Models
{
    public class ProjectModel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectModel"/> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public ProjectModel(Project entity)
        {
            ProjectId = entity.ProjectId;
            ClientId = entity.ClientId;
            ClientName = entity.Client.ClientName;
            ProjectName = entity.ProjectName;
            BillingCode = entity.BillingCode;
            QuickbooksProjectId = entity.QuickbooksProjectId;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectModel"/> class.
        /// </summary>
        public ProjectModel() { }

        /// <summary>
        /// Gets or sets the project id corresponding to the <see cref="ProjectModel"/>.
        /// </summary>
        /// <value>The project id.</value>
        public int ProjectId { get; set; }

        /// <summary>
        /// Gets or sets the client id corresponding to the <see cref="ProjectModel"/>.
        /// </summary>
        /// <value>The client id.</value>
        [UIHint("Client")]
        public int ClientId { get; set; }

        /// <summary>
        /// Gets or sets the name of the client.
        /// </summary>
        /// <value>The name of the client.</value>
        public string ClientName { get; set; }

        /// <summary>
        /// Gets or sets the name of the project.
        /// </summary>
        /// <value>The name of the project.</value>
        [Required]
        public string ProjectName { get; set; }

        /// <summary>
        /// Gets or sets the billing code corresponding to the <see cref="ProjectModel"/>.
        /// </summary>
        /// <value>The billing code.</value>
        public string BillingCode { get; set; }

        /// <summary>
        /// Gets or sets the quicken project id corresponding to the <see cref="ProjectModel"/>.
        /// </summary>
        /// <value>The quicken project id.</value>
        public string QuickbooksProjectId { get; set; }
    }

    /// <summary>
    /// Provides a class for the Drop-down
    /// </summary>
    public class ProjectDropDownDisplay
    {
        /// <summary>
        /// Gets or sets the project id.
        /// </summary>
        /// <value>The project id.</value>
        public int ProjectId { get; set; }

        /// <summary>
        /// Gets or sets the display name of the project.
        /// </summary>
        /// <value>The display name of the project.</value>
        public string ProjectDisplayName { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectDropDownDisplay"/> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public ProjectDropDownDisplay(Project entity)
        {
            ProjectId = entity.ProjectId;
            ProjectDisplayName = string.Format("{0} - {1}", entity.Client.ClientName, entity.ProjectName);
        }
    }
}